taxonomy.js ➔ Taxonomy   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 48

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 48
rs 9.125
c 0
b 0
f 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A taxonomy.js ➔ ... ➔ this._init 0 5 1
A taxonomy.js ➔ ... ➔ this._multipleSelect 0 7 1
A taxonomy.js ➔ ... ➔ this.delete 0 4 1
1
import select2 from 'select2';
2
3
var Taxonomy = function(className) {
4
5
    /**
6
     * taxonomy variable is created to represent Taxonomy instance.
7
     */
8
    var taxonomy = this;
9
10
    /**
11
     * element variable is created to represent master element of the Taxonomy.
12
     */
13
    var element = $(className);
14
15
    /**
16
     * selectElement variable is created to represent select input of the Taxonomy.
17
     */
18
    var selectElement = element.find('.taxonomy-multiple-select');
19
20
    /** 
21
     * Initialize actions.
22
     */
23
    this._init = function() {
24
        /* Initialize multiple select with select2 library. */
25
        taxonomy._multipleSelect();
26
        
27
    }
28
29
    /**
30
     * Initialize multiple select with select2 library.
31
     */
32
    this._multipleSelect = function() {
33
34
        selectElement.select2({
35
            placeholder: 'Please choose your terms'
36
        });
37
38
    }
39
40
    /**
41
     * Delete the Taxonomy.
42
     */ 
43
    this.delete = function() {
44
        /* Remove the taxonomy element. */
45
        element.remove();
46
    }
47
48
    taxonomy._init();
49
50
}
51
52
export default Taxonomy;